--
-- PostgreSQL database dump
--

-- Dumped from database version 9.0.4
-- Dumped by pg_dump version 9.0.3
-- Started on 2011-09-07 11:21:37

SET statement_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = off;
SET check_function_bodies = false;
SET client_min_messages = warning;
SET escape_string_warning = off;

--
-- TOC entry 326 (class 2612 OID 11574)
-- Name: plpgsql; Type: PROCEDURAL LANGUAGE; Schema: -; Owner: postgres
--

CREATE OR REPLACE PROCEDURAL LANGUAGE plpgsql;


ALTER PROCEDURAL LANGUAGE plpgsql OWNER TO postgres;

SET search_path = public, pg_catalog;

SET default_tablespace = '';

SET default_with_oids = false;

--
-- TOC entry 1518 (class 1259 OID 16500)
-- Dependencies: 1809 6
-- Name: canchas; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE canchas (
    canchas_id integer NOT NULL,
    descripcion character varying(50),
    sucursales_id integer NOT NULL,
    usuario character varying(50) NOT NULL,
    fecha_hora timestamp without time zone DEFAULT now()
);


ALTER TABLE public.canchas OWNER TO postgres;

--
-- TOC entry 1519 (class 1259 OID 16504)
-- Dependencies: 1518 6
-- Name: canchas_canchas_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE canchas_canchas_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.canchas_canchas_id_seq OWNER TO postgres;

--
-- TOC entry 1854 (class 0 OID 0)
-- Dependencies: 1519
-- Name: canchas_canchas_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE canchas_canchas_id_seq OWNED BY canchas.canchas_id;


--
-- TOC entry 1855 (class 0 OID 0)
-- Dependencies: 1519
-- Name: canchas_canchas_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--

SELECT pg_catalog.setval('canchas_canchas_id_seq', 1, false);


--
-- TOC entry 1520 (class 1259 OID 16506)
-- Dependencies: 1811 6
-- Name: clientes; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE clientes (
    clientes_id integer NOT NULL,
    apellido character varying(100) NOT NULL,
    nombre character varying(100) NOT NULL,
    dni character varying(8) NOT NULL,
    telefono character varying(30) NOT NULL,
    domicilio character varying(150),
    usuario character varying(50) NOT NULL,
    fecha_hora timestamp without time zone DEFAULT now()
);


ALTER TABLE public.clientes OWNER TO postgres;

--
-- TOC entry 1521 (class 1259 OID 16510)
-- Dependencies: 6 1520
-- Name: clientes_clientes_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE clientes_clientes_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.clientes_clientes_id_seq OWNER TO postgres;

--
-- TOC entry 1856 (class 0 OID 0)
-- Dependencies: 1521
-- Name: clientes_clientes_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE clientes_clientes_id_seq OWNED BY clientes.clientes_id;


--
-- TOC entry 1857 (class 0 OID 0)
-- Dependencies: 1521
-- Name: clientes_clientes_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--

SELECT pg_catalog.setval('clientes_clientes_id_seq', 1, false);


--
-- TOC entry 1522 (class 1259 OID 16512)
-- Dependencies: 1813 6
-- Name: empleados; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE empleados (
    empleados_id integer NOT NULL,
    apellido character varying(100) NOT NULL,
    nombre character varying(100) NOT NULL,
    dni character varying(8) NOT NULL,
    telefono character varying(30) NOT NULL,
    domicilio character varying(150) NOT NULL,
    fecha_nacimiento date NOT NULL,
    sucursales_id integer NOT NULL,
    usuario character varying(50) NOT NULL,
    fecha_hora timestamp without time zone DEFAULT now()
);


ALTER TABLE public.empleados OWNER TO postgres;

--
-- TOC entry 1523 (class 1259 OID 16516)
-- Dependencies: 6 1522
-- Name: empleados_empleados_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE empleados_empleados_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.empleados_empleados_id_seq OWNER TO postgres;

--
-- TOC entry 1858 (class 0 OID 0)
-- Dependencies: 1523
-- Name: empleados_empleados_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE empleados_empleados_id_seq OWNED BY empleados.empleados_id;


--
-- TOC entry 1859 (class 0 OID 0)
-- Dependencies: 1523
-- Name: empleados_empleados_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--

SELECT pg_catalog.setval('empleados_empleados_id_seq', 1, false);


--
-- TOC entry 1524 (class 1259 OID 16518)
-- Dependencies: 1815 6
-- Name: estados; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE estados (
    estados_id integer NOT NULL,
    descripcion character varying(50) NOT NULL,
    usuario character varying(50) NOT NULL,
    fecha_hora timestamp without time zone DEFAULT now()
);


ALTER TABLE public.estados OWNER TO postgres;

--
-- TOC entry 1525 (class 1259 OID 16522)
-- Dependencies: 1524 6
-- Name: estados_estados_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE estados_estados_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.estados_estados_id_seq OWNER TO postgres;

--
-- TOC entry 1860 (class 0 OID 0)
-- Dependencies: 1525
-- Name: estados_estados_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE estados_estados_id_seq OWNED BY estados.estados_id;


--
-- TOC entry 1861 (class 0 OID 0)
-- Dependencies: 1525
-- Name: estados_estados_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--

SELECT pg_catalog.setval('estados_estados_id_seq', 1, false);


--
-- TOC entry 1526 (class 1259 OID 16524)
-- Dependencies: 1817 6
-- Name: sucursales; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE sucursales (
    sucursales_id integer NOT NULL,
    descripcion character varying(100) NOT NULL,
    domicilio character varying(150) NOT NULL,
    telefono character varying(30) NOT NULL,
    usuario character varying(50) NOT NULL,
    fecha_hora timestamp without time zone DEFAULT now()
);


ALTER TABLE public.sucursales OWNER TO postgres;

--
-- TOC entry 1527 (class 1259 OID 16528)
-- Dependencies: 1526 6
-- Name: sucursales_sucursales_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE sucursales_sucursales_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.sucursales_sucursales_id_seq OWNER TO postgres;

--
-- TOC entry 1862 (class 0 OID 0)
-- Dependencies: 1527
-- Name: sucursales_sucursales_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE sucursales_sucursales_id_seq OWNED BY sucursales.sucursales_id;


--
-- TOC entry 1863 (class 0 OID 0)
-- Dependencies: 1527
-- Name: sucursales_sucursales_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--

SELECT pg_catalog.setval('sucursales_sucursales_id_seq', 1, false);


--
-- TOC entry 1528 (class 1259 OID 16530)
-- Dependencies: 6
-- Name: turnos; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE turnos (
    turnos_id integer NOT NULL,
    fecha timestamp without time zone NOT NULL,
    hora_comienzo time without time zone NOT NULL,
    hora_fin time without time zone NOT NULL,
    estado integer NOT NULL,
    sucursales_id integer NOT NULL,
    clientes_id integer NOT NULL,
    canchas_id integer NOT NULL
);


ALTER TABLE public.turnos OWNER TO postgres;

--
-- TOC entry 1529 (class 1259 OID 16533)
-- Dependencies: 6 1528
-- Name: turnos_turnos_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE turnos_turnos_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.turnos_turnos_id_seq OWNER TO postgres;

--
-- TOC entry 1864 (class 0 OID 0)
-- Dependencies: 1529
-- Name: turnos_turnos_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE turnos_turnos_id_seq OWNED BY turnos.turnos_id;


--
-- TOC entry 1865 (class 0 OID 0)
-- Dependencies: 1529
-- Name: turnos_turnos_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--

SELECT pg_catalog.setval('turnos_turnos_id_seq', 1, false);


--
-- TOC entry 1530 (class 1259 OID 16535)
-- Dependencies: 6
-- Name: usuarios; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE usuarios (
    usuarios_id integer NOT NULL,
    username character varying(50) NOT NULL,
    password character varying(50) NOT NULL
);


ALTER TABLE public.usuarios OWNER TO postgres;

--
-- TOC entry 1531 (class 1259 OID 16538)
-- Dependencies: 1530 6
-- Name: usuarios_usuarios_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE usuarios_usuarios_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.usuarios_usuarios_id_seq OWNER TO postgres;

--
-- TOC entry 1866 (class 0 OID 0)
-- Dependencies: 1531
-- Name: usuarios_usuarios_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE usuarios_usuarios_id_seq OWNED BY usuarios.usuarios_id;


--
-- TOC entry 1867 (class 0 OID 0)
-- Dependencies: 1531
-- Name: usuarios_usuarios_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--

SELECT pg_catalog.setval('usuarios_usuarios_id_seq', 1, false);


--
-- TOC entry 1810 (class 2604 OID 16540)
-- Dependencies: 1519 1518
-- Name: canchas_id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE canchas ALTER COLUMN canchas_id SET DEFAULT nextval('canchas_canchas_id_seq'::regclass);


--
-- TOC entry 1812 (class 2604 OID 16541)
-- Dependencies: 1521 1520
-- Name: clientes_id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE clientes ALTER COLUMN clientes_id SET DEFAULT nextval('clientes_clientes_id_seq'::regclass);


--
-- TOC entry 1814 (class 2604 OID 16542)
-- Dependencies: 1523 1522
-- Name: empleados_id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE empleados ALTER COLUMN empleados_id SET DEFAULT nextval('empleados_empleados_id_seq'::regclass);


--
-- TOC entry 1816 (class 2604 OID 16543)
-- Dependencies: 1525 1524
-- Name: estados_id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE estados ALTER COLUMN estados_id SET DEFAULT nextval('estados_estados_id_seq'::regclass);


--
-- TOC entry 1818 (class 2604 OID 16544)
-- Dependencies: 1527 1526
-- Name: sucursales_id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE sucursales ALTER COLUMN sucursales_id SET DEFAULT nextval('sucursales_sucursales_id_seq'::regclass);


--
-- TOC entry 1819 (class 2604 OID 16545)
-- Dependencies: 1529 1528
-- Name: turnos_id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE turnos ALTER COLUMN turnos_id SET DEFAULT nextval('turnos_turnos_id_seq'::regclass);


--
-- TOC entry 1820 (class 2604 OID 16546)
-- Dependencies: 1531 1530
-- Name: usuarios_id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE usuarios ALTER COLUMN usuarios_id SET DEFAULT nextval('usuarios_usuarios_id_seq'::regclass);


--
-- TOC entry 1842 (class 0 OID 16500)
-- Dependencies: 1518
-- Data for Name: canchas; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- TOC entry 1843 (class 0 OID 16506)
-- Dependencies: 1520
-- Data for Name: clientes; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- TOC entry 1844 (class 0 OID 16512)
-- Dependencies: 1522
-- Data for Name: empleados; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- TOC entry 1845 (class 0 OID 16518)
-- Dependencies: 1524
-- Data for Name: estados; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- TOC entry 1846 (class 0 OID 16524)
-- Dependencies: 1526
-- Data for Name: sucursales; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- TOC entry 1847 (class 0 OID 16530)
-- Dependencies: 1528
-- Data for Name: turnos; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- TOC entry 1848 (class 0 OID 16535)
-- Dependencies: 1530
-- Data for Name: usuarios; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- TOC entry 1822 (class 2606 OID 16548)
-- Dependencies: 1518 1518
-- Name: canchas_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY canchas
    ADD CONSTRAINT canchas_pkey PRIMARY KEY (canchas_id);


--
-- TOC entry 1824 (class 2606 OID 16550)
-- Dependencies: 1520 1520
-- Name: clientes_dni_key; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY clientes
    ADD CONSTRAINT clientes_dni_key UNIQUE (dni);


--
-- TOC entry 1826 (class 2606 OID 16552)
-- Dependencies: 1520 1520
-- Name: clientes_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY clientes
    ADD CONSTRAINT clientes_pkey PRIMARY KEY (clientes_id);


--
-- TOC entry 1828 (class 2606 OID 16554)
-- Dependencies: 1522 1522
-- Name: empleados_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY empleados
    ADD CONSTRAINT empleados_pkey PRIMARY KEY (empleados_id);


--
-- TOC entry 1830 (class 2606 OID 16556)
-- Dependencies: 1524 1524
-- Name: estados_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY estados
    ADD CONSTRAINT estados_pkey PRIMARY KEY (estados_id);


--
-- TOC entry 1832 (class 2606 OID 16558)
-- Dependencies: 1526 1526
-- Name: sucursales_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY sucursales
    ADD CONSTRAINT sucursales_pkey PRIMARY KEY (sucursales_id);


--
-- TOC entry 1834 (class 2606 OID 16560)
-- Dependencies: 1528 1528
-- Name: turnos_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY turnos
    ADD CONSTRAINT turnos_pkey PRIMARY KEY (turnos_id);


--
-- TOC entry 1836 (class 2606 OID 16562)
-- Dependencies: 1530 1530
-- Name: usuarios_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY usuarios
    ADD CONSTRAINT usuarios_pkey PRIMARY KEY (usuarios_id);


--
-- TOC entry 1839 (class 2606 OID 16563)
-- Dependencies: 1518 1821 1528
-- Name: canchas_id; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY turnos
    ADD CONSTRAINT canchas_id FOREIGN KEY (canchas_id) REFERENCES canchas(canchas_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- TOC entry 1840 (class 2606 OID 16568)
-- Dependencies: 1825 1528 1520
-- Name: clientes_id; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY turnos
    ADD CONSTRAINT clientes_id FOREIGN KEY (clientes_id) REFERENCES clientes(clientes_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- TOC entry 1841 (class 2606 OID 16573)
-- Dependencies: 1831 1526 1528
-- Name: sucursales_id; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY turnos
    ADD CONSTRAINT sucursales_id FOREIGN KEY (sucursales_id) REFERENCES sucursales(sucursales_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- TOC entry 1838 (class 2606 OID 16578)
-- Dependencies: 1831 1526 1522
-- Name: sucursales_id; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY empleados
    ADD CONSTRAINT sucursales_id FOREIGN KEY (sucursales_id) REFERENCES sucursales(sucursales_id);


--
-- TOC entry 1837 (class 2606 OID 16583)
-- Dependencies: 1831 1526 1518
-- Name: sucursales_id; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY canchas
    ADD CONSTRAINT sucursales_id FOREIGN KEY (sucursales_id) REFERENCES sucursales(sucursales_id);


--
-- TOC entry 1853 (class 0 OID 0)
-- Dependencies: 6
-- Name: public; Type: ACL; Schema: -; Owner: postgres
--

REVOKE ALL ON SCHEMA public FROM PUBLIC;
REVOKE ALL ON SCHEMA public FROM postgres;
GRANT ALL ON SCHEMA public TO postgres;
GRANT ALL ON SCHEMA public TO PUBLIC;


-- Completed on 2011-09-07 11:21:37

--
-- PostgreSQL database dump complete
--

